﻿@model IEnumerable<NorthwindMVC.Models.Order>

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>

<h3>
    <div class="tablecontainer">
        <div class="row">
            <div class="order customer cell left3">
                <text>@Html.DisplayNameFor(model => model.Customer.CompanyName)</text>
            </div>
            <div class="order date cell middle3">
                <text>@Html.DisplayNameFor(model => model.OrderDate)</text>
            </div>
            <div class="order amount cell right3">
                <text>Order Total</text>
            </div>
        </div>
    </div>
</h3>

<div id="accordion">

    @foreach (var item in Model)
    {
        <h3>
            <div class="tablecontainer margin10">
                <div class="row">
                    <div class="order customer cell left3">
                        @Html.DisplayFor(modelItem => item.Customer.CompanyName)
                    </div>
                    <div class="order date cell middle3">
                        @Html.DisplayFor(modelItem => item.OrderDate)
                    </div>
                    <div class="order amount cell right3">
                        @NorthwindMVC.Controllers.OrderController.getOrderTotal(item.Order_Details)
                    </div>
                </div>
            </div>
        </h3>
        <div>
            <p>
                <div class="tablecontainer">
                    <div class="row">
                        <div class="cell left">
                            <div>
                                <span class="bold">@Html.DisplayNameFor(model => model.RequiredDate):&nbsp;</span>@Html.DisplayFor(modelItem => item.RequiredDate)
                            </div>
                            <div>
                                <span class="bold">@Html.DisplayNameFor(model => model.ShippedDate):&nbsp;</span>@Html.DisplayFor(modelItem => item.ShippedDate)
                            </div>
                            <div>
                                <span class="bold">@Html.DisplayNameFor(model => model.Shipper.CompanyName):&nbsp;</span>@Html.DisplayFor(modelItem => item.Shipper.CompanyName)
                            </div>
                            <div>
                                <span class="bold">@Html.DisplayNameFor(model => model.Freight):&nbsp;</span>@Html.DisplayFor(modelItem => item.Freight)
                            </div>
                            <div>
                                <span class="bold">@Html.DisplayNameFor(model => model.ShipName):&nbsp;</span>@Html.DisplayFor(modelItem => item.ShipName)
                            </div>
                        </div>
                        <div class="spacer">&nbsp;</div>
                        <div class="cell right">
                            <div>
                                <span class="bold">@Html.DisplayNameFor(model => model.ShipAddress):&nbsp;</span>@Html.DisplayFor(modelItem => item.ShipAddress)
                            </div>
                            <div>
                                <span class="bold">@Html.DisplayNameFor(model => model.ShipCity):&nbsp;</span>@Html.DisplayFor(modelItem => item.ShipCity)
                            </div>
                            <div>
                                <span class="bold">@Html.DisplayNameFor(model => model.ShipRegion):&nbsp;</span>@Html.DisplayFor(modelItem => item.ShipRegion)
                            </div>
                            <div>
                                <span class="bold">@Html.DisplayNameFor(model => model.ShipPostalCode):&nbsp;</span>@Html.DisplayFor(modelItem => item.ShipPostalCode)
                            </div>
                            <div>
                                <span class="bold">@Html.DisplayNameFor(model => model.ShipCountry):&nbsp;</span>@Html.DisplayFor(modelItem => item.ShipCountry)
                            </div>
                        </div>
                    </div>
                </div>
                @Html.Partial("OrderDetailsPartial", item.Order_Details)
            </p>
        </div>
    }
</div>

<script type="text/javascript">
    window.onload = function () {
        $("#accordion").accordion({
            autoHeight: 'false',
            heightStyle: 'content',
            collapsible: true,
            active: false
        });
    }
</script>

<span>
@*<table>
            <tr>
                <th>
                    @Html.DisplayNameFor(model => model.Customer.CompanyName)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.Employee.LastName)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.OrderDate)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.RequiredDate)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.ShippedDate)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.Shipper.CompanyName)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.Freight)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.ShipName)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.ShipAddress)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.ShipCity)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.ShipRegion)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.ShipPostalCode)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.ShipCountry)
                </th>
                <th></th>
            </tr>

            @foreach (var item in Model) {
                <tr>
                    <td>
                        @Html.DisplayFor(modelItem => item.Customer.CompanyName)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Employee.LastName)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.OrderDate)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.RequiredDate)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.ShippedDate)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Shipper.CompanyName)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Freight)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.ShipName)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.ShipAddress)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.ShipCity)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.ShipRegion)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.ShipPostalCode)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.ShipCountry)
                    </td>
                    <td>
                        @Html.ActionLink("Edit", "Edit", new { id=item.OrderID }) |
                        @Html.ActionLink("Details", "Details", new { id=item.OrderID }) |
                        @Html.ActionLink("Delete", "Delete", new { id=item.OrderID })
                    </td>
                </tr>
    }

        </table>*@
</span>
